﻿' <summary>
' BeeWit IDE Entorno de desarrollo Visual para php.
' BeeWitPHP IDE es el único entorno de desarrollo para PHP 
' de tipo WYSIWYG (What You See Is What You Get). 
' ¡Ahora si!, aproveche la potencia del lenguaje PHP 
' y desarrolle más rápidamente gracias a la programación 
' intuitiva de BeeWit.
' Copyright © 2010 Dewins Murillo Garcia 
' EMAIL: dewinsmg@gmail.com
' EMAIL: dewins@beewitsoft.com
' Este Programa es Software Libre: usted puede redistribuirlo 
' y/o modificarlo bajo los términos de la Licencia Publica General 
' GNU como es publicada por la Fundacion de Software Libre; 
' en la 3ra versión de la licencia.
' Este programa es distribuido con la esperanza de que sea útil, 
' pero SIN GARANTÍA ALGUNA; sin siquiera la garantía implícita 
' de VALOR COMERCIAL o FORMADO PARA UN PROPÓSITO EN PARTICULAR. 
' Vea la Licencia Publica General GNU para mas detalles.
' Usted debe haber recibido una copia de la Licencia Publica General 
' GNU junto con este programa. Si no, vaya a http://www.beewitsoft.com
' o en http://code.google.com/p/ajax-beewit-php-ide/
' </summary>
' <remarks></remarks>

Imports Fireball.Windows.Forms.CodeEditor
Imports Fireball.CodeEditor.SyntaxFiles
Imports Fireball.Syntax
Imports Fireball.Windows.Forms
Imports Fireball.Plugins.Dialogs
Imports FireEdit.caret
Imports FireEdit.Dialogs
Imports Fireball.Docking

Public Class clsEditorCode
    Inherits CodeEditorControl

#Region "declarations"
    Private objAutoComplete As New clsAutoComplete
    Private _ClassCode As String
    'Private CurrentWord As String
    Private _TypeContent As TypeContent
    Public Node As clsNode
    Public WithEvents cboObjects As New Talex.Controls.ImageCombo.ImageCombo
    Public WithEvents cboMethods As New Talex.Controls.ImageCombo.ImageCombo
    Public CanFillComboObjects As Boolean = False
    Public CanFillComboMethods As Boolean = False
#End Region

    Structure AutoListWord
        Dim toShow As String
        Dim toInsert As String
        Dim Comment As String
        Dim ImageKey As Long
    End Structure

    Enum TypeContent
        isVIEW
        isCODE
    End Enum

    Enum TypeWord
        isTHISOBJECT
        isOTHEROBJECT
        isNEWOBJECT
        NONE
    End Enum

    Enum Ambit
        NONE
        isPRIVATE
        isPUBLIC
        isPROTECTED
        ALL
    End Enum

    Structure ScanWord
        Dim Type As TypeWord
        Dim ClassName As String
        Dim ClassPath As String
        Dim ClassCode As String
    End Structure

    Property ContentType() As TypeContent
        Get
            Return _TypeContent
        End Get
        Set(ByVal value As TypeContent)
            _TypeContent = value
        End Set
    End Property

    Property ClassCode() As String
        Get
            Return _ClassCode
        End Get
        Set(ByVal value As String)
            _ClassCode = value
        End Set
    End Property

    Private Sub clsEditorCode_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Try
            If Me.ContentType = TypeContent.isCODE Then
                Me.Node.ContentCode = Me.Document.Text
            End If
            If Me.ContentType = TypeContent.isVIEW Then
                Me.Node.ContentView = Me.Document.Text
            End If
            If e.Control And e.KeyCode = 83 Then
                Control_Main.Save()
            End If
            If e.KeyCode = Keys.Down Or e.KeyCode = Keys.Up Or e.KeyCode = Keys.Escape Or e.KeyCode = Keys.Next Or e.KeyCode = Keys.Prior Then
                If e.KeyCode = Keys.Escape Then
                    Me.AutoListVisible = False
                    Me.AutoListClear()
                    e.SuppressKeyPress = True
                End If
            Else
                ListAutoComplete() 'FILL AUTO COMPLETE LIST
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub clsEditorCode_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.AutoListIcons = Object_Icons.bmpImageList
    End Sub

    Private Sub clsEditorCode_RowClick(ByVal sender As Object, ByVal e As Fireball.Windows.Forms.CodeEditor.RowMouseEventArgs) Handles Me.RowClick
        Me.AutoListVisible = False
        Me.AutoListClear()
    End Sub

    Public Sub FillComboObjects()
        Dim AutoListCount As Long = 0
        Dim ClassNameInherit As String = ""
        Me.AutoListVisible = False
        Me.AutoListClear()
        Me.cboObjects.Items.Clear()
        CanFillComboObjects = True
        CanFillComboMethods = False
        AutoListCount += ListVars(Me.Node.ContentCode, Ambit.ALL)
        AutoListCount += ListMethods(Me.Node.ContentCode, Ambit.ALL)
        ClassNameInherit = Object_Expression.GetClassNameInherits(Me.Node.ContentCode)
        Dim NodeFound As clsNode = Control_Explorer.SearchClass(ClassNameInherit)
        If Not NodeFound Is Nothing Then
            AutoListCount += ListVars(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
            AutoListCount += ListMethods(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
        End If
        CanFillComboObjects = False
        CanFillComboMethods = False
    End Sub

    Private Sub ListAutoComplete(Optional ByVal CurrentWord As String = "")
        Dim AutoListCount As Long = 0
        Dim ClassNameInherit As String = ""
        Me.AutoListVisible = False
        Me.AutoListClear()
        If CurrentWord = "" Then
            If Not Me.Caret.CurrentWord Is Nothing Then
                CurrentWord = Me.Caret.CurrentWord.Text
            End If
        End If
        If CurrentWord = "[" Then
            Exit Sub
        End If
        If CurrentWord <> "" Then 'si hay una palabra digitada
            Me.AutoListVisible = False
            If CurrentWord <> "" Then
                Dim ScanedCurrentWord As ScanWord = GetWordType(CurrentWord)
                Me.AutoListBeginLoad()

                If ScanedCurrentWord.Type = TypeWord.isTHISOBJECT Then
                    AutoListCount += ListVars(Me.Node.ContentCode, Ambit.ALL)
                    AutoListCount += ListMethods(Me.Node.ContentCode, Ambit.ALL)
                    ClassNameInherit = Object_Expression.GetClassNameInherits(Me.Node.ContentCode)
                    Dim NodeFound As clsNode = Control_Explorer.SearchClass(ClassNameInherit)
                    If Not NodeFound Is Nothing Then
                        AutoListCount += ListVars(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                        AutoListCount += ListMethods(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                        ClassNameInherit = Object_Expression.GetClassNameInherits(NodeFound.ContentCode)
                        NodeFound = Control_Explorer.SearchClass(ClassNameInherit)
                        If Not NodeFound Is Nothing Then
                            AutoListCount += ListVars(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                            AutoListCount += ListMethods(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                        End If
                    End If
                End If
                If ScanedCurrentWord.Type = TypeWord.isOTHEROBJECT Then
                    AutoListCount += ListVars(ScanedCurrentWord.ClassCode, Ambit.isPUBLIC)
                    AutoListCount = ListProperties(ScanedCurrentWord.ClassCode, clsEditorCode.Ambit.isPROTECTED, "")
                    AutoListCount += ListMethods(ScanedCurrentWord.ClassCode, Ambit.isPUBLIC)
                    AutoListCount += ListEvents(ScanedCurrentWord.ClassCode, Ambit.isPUBLIC, , , CurrentWord)
                    ClassNameInherit = Object_Expression.GetClassNameInherits(ScanedCurrentWord.ClassCode)
                    Dim NodeFound As clsNode = Control_Explorer.SearchClass(ClassNameInherit)
                    If Not NodeFound Is Nothing Then
                        AutoListCount += ListVars(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                        AutoListCount += ListMethods(NodeFound.ContentCode, Ambit.isPROTECTED, " ::" & ClassNameInherit)
                    End If
                End If
                If CurrentWord = "$" Then
                    Dim NumberLine As Long = Me.Caret.Position.Y
                    Dim TextLines() As String = Me.Document.Lines
                    Dim PartialContent As String = ""
                    For i = NumberLine To 1 Step -1
                        PartialContent = TextLines(i).ToString & vbCrLf & PartialContent
                        If TextLines(i).ToString.ToUpper Like "*FUNCTION*" Then
                            Exit For
                        End If
                    Next
                    AutoListCount += ListLocalVars(PartialContent, Ambit.NONE)
                End If

                If CurrentWord.ToUpper = "$THIS" Then
                    Dim IconKey As String = "icon_method"
                    Dim NewItemBeforeLoad As New Talex.Controls.ImageCombo.ComboBoxImageItem("before_load", IconKey, "before load the control")
                    Dim NewItemAfterLoad As New Talex.Controls.ImageCombo.ComboBoxImageItem("after_load", IconKey, "after load the control")
                    Me.cboMethods.Items.Add(NewItemBeforeLoad)
                    Me.cboMethods.Items.Add(NewItemAfterLoad)
                End If

                If ScanedCurrentWord.Type = TypeWord.isNEWOBJECT Then
                    AutoListCount += ListClasses()
                End If
                If ScanedCurrentWord.Type = TypeWord.NONE Then
                    AutoListCount += ListPHPFunctions(CurrentWord)
                End If
                If Not CanFillComboMethods Then
                    If AutoListCount > 0 Then
                        Me.AutoListEndLoad()
                        Me.AutoListVisible = True
                        Me.AutoListPosition = New TextPoint(Me.Caret.CurrentWord.Column + CurrentWord.Length, Me.Caret.Position.Y)
                    End If
                End If
            End If
        End If
    End Sub

    Public Function ListVars(ByVal Content As String, ByVal VarAmbit As Ambit, Optional ByVal Comment As String = "", Optional ByRef ListedVars() As clsRegExpr.Vars = Nothing) As Long
        Dim Vars() As clsRegExpr.Vars = Object_Expression.GetVars(Content)
        'Dim Listed(Vars.Length) As String
        If Vars Is Nothing Then
            Exit Function
        End If
        ListVars = 0
        Dim Listed(Vars.Length) As clsRegExpr.Vars
        If Not Vars Is Nothing Then
            Dim isListed As Boolean = False
            For Each var As clsRegExpr.Vars In Vars
                Dim VarAmbitFound As Ambit = Ambit.NONE
                If var.VarAmbit.ToUpper = "PRIVATE" Then VarAmbitFound = Ambit.isPRIVATE
                If var.VarAmbit.ToUpper = "PUBLIC" Then VarAmbitFound = Ambit.isPUBLIC
                If var.VarAmbit.ToUpper = "PROTECTED" Then VarAmbitFound = Ambit.isPROTECTED
                If var.VarAmbit.ToUpper = "NONE" Then VarAmbitFound = Ambit.NONE
                If VarAmbitFound = VarAmbit Or VarAmbit = Ambit.ALL Then
                    Dim ScanedCurrentWord As ScanWord = GetWordType(var.VarName)
                    Dim IconKey As String = "icon_property"
                    isListed = False
                    For Each ListedValue As clsRegExpr.Vars In Listed
                        If ListedValue.VarName = var.VarName Then
                            isListed = True
                        End If
                    Next
                    If ScanedCurrentWord.Type = TypeWord.isOTHEROBJECT Or var.VarName.ToUpper = "THIS" Then
                        IconKey = "icon_object"
                    End If
                    If Not isListed Then
                        If AutoListAddItem(var.VarName, "->" & var.VarName, var.VarComment & Comment, IconKey) = True Then
                            Listed(ListVars).VarName = var.VarName
                            Listed(ListVars).VarComment = var.VarComment
                            ListVars += 1
                            If CanFillComboObjects Then
                                Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                                Me.cboObjects.Items.Add(NewItem)
                            End If
                            If CanFillComboMethods Then
                                Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                                Me.cboMethods.Items.Add(NewItem)
                            End If
                        End If
                    End If

                End If
            Next
        End If
        If Not ListedVars Is Nothing Then
            ListedVars = Listed
        End If
    End Function

    Public Function ListProperties(ByVal Content As String, ByVal VarAmbit As Ambit, Optional ByVal Comment As String = "", Optional ByRef ListedVars() As clsRegExpr.Vars = Nothing) As Long
        Dim Vars() As clsRegExpr.Vars = Object_Expression.GetProperties(Content)
        'Dim Listed(Vars.Length) As String
        If Vars Is Nothing Then
            Exit Function
        End If
        Dim Listed(Vars.Length) As clsRegExpr.Vars
        Dim isListed As Boolean = False
        ListProperties = 0
        If Not Vars Is Nothing Then
            For Each var As clsRegExpr.Vars In Vars
                Dim VarAmbitFound As Ambit = Ambit.NONE
                If var.VarAmbit.ToUpper = "PRIVATE" Then VarAmbitFound = Ambit.isPRIVATE
                If var.VarAmbit.ToUpper = "PUBLIC" Then VarAmbitFound = Ambit.isPUBLIC
                If var.VarAmbit.ToUpper = "PROTECTED" Then VarAmbitFound = Ambit.isPROTECTED
                If var.VarAmbit.ToUpper = "NONE" Then VarAmbitFound = Ambit.NONE
                If VarAmbitFound = VarAmbit Or VarAmbit = Ambit.ALL Then
                    Dim ScanedCurrentWord As ScanWord = GetWordType(var.VarName)
                    Dim IconKey As String = "icon_property"
                    isListed = False
                    For Each ListedValue As clsRegExpr.Vars In Listed
                        If ListedValue.VarName = var.VarName Then
                            isListed = True
                        End If
                    Next
                    If ScanedCurrentWord.Type = TypeWord.isOTHEROBJECT Or var.VarName.ToUpper = "THIS" Then
                        IconKey = "icon_object"
                    End If
                    If Not isListed Then
                        If AutoListAddItem(var.VarName, "->" & var.VarName, var.VarComment & Comment, IconKey) = True Then
                            Listed(ListProperties).VarName = var.VarName
                            Listed(ListProperties).VarComment = var.VarComment
                            ListProperties += 1
                            If CanFillComboObjects Then
                                Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                                Me.cboObjects.Items.Add(NewItem)
                            End If
                            If CanFillComboMethods Then
                                Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                                Me.cboMethods.Items.Add(NewItem)
                            End If
                        End If
                    End If

                End If
            Next
        End If
        If Not ListedVars Is Nothing Then
            ListedVars = Listed
        End If
    End Function

    Public Function ListMethods(ByVal Content As String, ByVal VarAmbit As Ambit, Optional ByVal Comment As String = "", Optional ByRef ListedMethods() As clsRegExpr.Methods = Nothing) As Long
        Dim Methods() As clsRegExpr.Methods = Object_Expression.GetMethods(Content)
        If Methods Is Nothing Then
            Exit Function
        End If
        Dim Listed(Methods.Length) As clsRegExpr.Methods
        ListMethods = 0
        If Not Methods Is Nothing Then
            For Each Method As clsRegExpr.Methods In Methods
                Dim MethodAmbitFound As Ambit = Ambit.NONE
                If Method.MethodAmbit.ToUpper = "PRIVATE" Then MethodAmbitFound = Ambit.isPRIVATE
                If Method.MethodAmbit.ToUpper = "PUBLIC" Then MethodAmbitFound = Ambit.isPUBLIC
                If Method.MethodAmbit.ToUpper = "PROTECTED" Then MethodAmbitFound = Ambit.isPROTECTED
                If Method.MethodAmbit.ToUpper = "NONE" Then MethodAmbitFound = Ambit.NONE
                If MethodAmbitFound = VarAmbit Or VarAmbit = Ambit.ALL Then
                    Dim ScanedCurrentWord As ScanWord = GetWordType(Method.MethodName)
                    If AutoListAddItem(Method.MethodName & "(" & Method.MethodParameters & ");", "->" & Method.MethodName & "(" & Method.MethodParameters & ");", Method.MethodComment & Comment, "icon_method") = True Then
                        Listed(ListMethods).MethodName = Method.MethodName
                        Listed(ListMethods).MethodComment = Method.MethodComment
                        Listed(ListMethods).MethodParameters = Method.MethodParameters
                        ListMethods += 1
                        If CanFillComboMethods Then
                            Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(Method.MethodName, "icon_method", Method.MethodComment)
                            Me.cboMethods.Items.Add(NewItem)
                        End If
                    End If
                End If
            Next
        End If
        ListedMethods = Listed
    End Function

    Public Function ListEvents(ByVal Content As String, ByVal VarAmbit As Ambit, Optional ByVal Comment As String = "", Optional ByRef ListedEvents() As clsRegExpr.Events = Nothing, Optional ByVal CurrentWord As String = "CURRENTWORD") As Long
        Dim Events() As clsRegExpr.Events = Object_Expression.GetEvents(Content)
        If Events Is Nothing Then
            Exit Function
        End If
        Dim Listed(Events.Length) As clsRegExpr.Events
        ListEvents = 0
        If Not Events Is Nothing Then
            For Each iEvent As clsRegExpr.Events In Events
                Dim ScanedCurrentWord As ScanWord = GetWordType(iEvent.EventName)
                Dim EventName As String = iEvent.EventName
                If EventName Like "*___*" Then
                    EventName = Replace(EventName, "___", "_" & CurrentWord & "_")
                End If
                If AutoListAddItem(EventName & "(...);", "->" & EventName & "();", Comment, "icon_method") = True Then
                    Listed(ListEvents).EventName = EventName
                    ListEvents += 1
                End If
                If CanFillComboMethods Then
                    Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(EventName, "icon_method", "...")
                    Me.cboMethods.Items.Add(NewItem)
                End If
            Next
        End If
        ListedEvents = Listed
    End Function

    Private Function ListLocalVars(ByVal Content As String, ByVal VarAmbit As Ambit, Optional ByVal Comment As String = "") As Long
        Dim Vars() As clsRegExpr.Vars = Object_Expression.GetVars(Content)
        ListLocalVars = 0
        If Not Vars Is Nothing Then
            For Each var As clsRegExpr.Vars In Vars
                Dim VarAmbitFound As Ambit = Ambit.NONE
                If var.VarAmbit.ToUpper = "PRIVATE" Then VarAmbitFound = Ambit.isPRIVATE
                If var.VarAmbit.ToUpper = "PUBLIC" Then VarAmbitFound = Ambit.isPUBLIC
                If var.VarAmbit.ToUpper = "PROTECTED" Then VarAmbitFound = Ambit.isPROTECTED
                If var.VarAmbit.ToUpper = "NONE" Then VarAmbitFound = Ambit.NONE
                If VarAmbitFound = VarAmbit Or VarAmbit = Ambit.ALL Then
                    Dim IconKey As String = "icon_property"
                    If var.VarName.ToUpper = "THIS" Then
                        IconKey = "icon_object"
                    End If
                    If AutoListAddItem(var.VarName, "" & var.VarName, var.VarComment & Comment, IconKey) = True Then
                        ListLocalVars += 1
                        If CanFillComboObjects Then
                            Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                            Me.cboObjects.Items.Add(NewItem)
                        End If
                        If CanFillComboMethods Then
                            Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(var.VarName, IconKey, var.VarComment)
                            Me.cboMethods.Items.Add(NewItem)
                        End If
                    End If
                End If
            Next
        End If
    End Function

    Private Function ListClasses() As Long
        Dim NodeClasses() As clsNode = Control_Explorer.SearchClasses
        Dim IconKey As String = "icon_object"
        ListClasses = 0
        If Not NodeClasses Is Nothing Then
            For Each ClassNode As clsNode In NodeClasses
                Dim ClassName As String = Object_Expression.GetClassName(ClassNode.ContentCode)
                'If AutoListAddItem(ClassName, " " & ClassName & "($this);", "", "icon_property") = True Then
                If AutoListAddItem(ClassName, " " & ClassName & "($this);", ClassName, IconKey) = True Then
                    ListClasses += 1
                    If CanFillComboObjects Then
                        Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(ClassName, IconKey, ClassName)
                        Me.cboObjects.Items.Add(NewItem)
                    End If
                    If CanFillComboMethods Then
                        Dim NewItem As New Talex.Controls.ImageCombo.ComboBoxImageItem(ClassName, IconKey, ClassName)
                        Me.cboMethods.Items.Add(NewItem)
                    End If
                End If
            Next
        End If
    End Function

    Private Function ListPHPFunctions(ByVal CurrentWord As String) As Long
        If General.Control_Main.ActualEditor.btnCode.Enabled = False Then
            Dim VarFunctions() As clsPhpFunctions.PhpFunctions = Object_PhpFunctions.GetFunctions(CurrentWord)
            Dim IconKey As String = "icon_method"
            ListPHPFunctions = 0
            If Not VarFunctions Is Nothing Then
                For Each aFunction As clsPhpFunctions.PhpFunctions In VarFunctions
                    Dim FunctionName As String = aFunction.PhpFunctionName
                    Dim Description As String = aFunction.PhpFunctionDescription
                    Dim Parameters As String = aFunction.PhpFunctionParameters
                    Dim WordToInsert As String = ""
                    If FunctionName.Length > CurrentWord.Length Then
                        Dim ShortFunctionName As String = FunctionName.Substring(0, CurrentWord.Length)
                        If ShortFunctionName = CurrentWord Then
                            WordToInsert = FunctionName.Substring(CurrentWord.Length)
                            If AutoListAddItem(FunctionName & "(" & Parameters & ")", WordToInsert & "(" & Parameters & ")", Description, IconKey) = True Then
                                ListPHPFunctions += 1
                            End If
                        End If
                    End If
                Next
            End If
        End If
    End Function

    Private Function AutoListAddItem(ByVal toShow As String, ByVal toInsert As String, ByVal Comment As String, ByVal ImageKey As String) As Boolean
        Me.AutoListAdd(toShow, toInsert, Comment, Object_Icons.IndexOfKey(ImageKey))
        Return True
    End Function

    Private Function GetWordType(ByVal Word As String) As ScanWord
        Dim Data As New ScanWord
        Data.Type = TypeWord.NONE
        Dim Content As String
        If Me._TypeContent = TypeContent.isCODE Then
            Content = Me.Node.ContentCode
        Else
            Content = Me.Node.ContentView
        End If
        If Word.ToUpper = "NEW" Then
            Data.Type = TypeWord.isNEWOBJECT
            Data.ClassName = ""
        Else
            If Word.ToUpper = "$THIS" Then
                Data.Type = TypeWord.isTHISOBJECT
                Data.ClassName = ""
            Else
                Dim Objects() As clsRegExpr.InstancedObject = Object_Expression.GetInstancedObjects(Content)
                If Not Objects Is Nothing Then
                    For Each objInstanced As clsRegExpr.InstancedObject In Objects
                        Dim Name As String = objInstanced.VarName
                        Dim ClassName As String = objInstanced.ClassName
                        If Name.Replace("$", "") = Word.Replace("$", "") Then
                            Data.Type = TypeWord.isOTHEROBJECT
                            Data.ClassName = ClassName
                            Dim NodeFound As clsNode = Control_Explorer.SearchClass(ClassName)
                            If Not NodeFound Is Nothing Then
                                Data.ClassPath = NodeFound.Path
                                Data.ClassCode = NodeFound.ContentCode
                            Else
                                If Not String.IsNullOrEmpty(ClassName) Then
                                    Control_Console.AddMessages("[" & ClassName & "] no found!!.  ", ctlConsole.enumTypeMessages.isWARNING)
                                End If

                            End If
                        End If
                    Next
                End If
            End If
        End If
        Return Data
    End Function

    Private Sub cboObjects_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboObjects.SelectedIndexChanged
        Dim CurrentWord As String = ""
        CanFillComboObjects = False
        CanFillComboMethods = True
        Me.cboMethods.Items.Clear()
        CurrentWord = sender.text
        If sender.text.ToString.ToUpper = "THIS" Then
            CurrentWord = "$this"
        End If
        ListAutoComplete(CurrentWord)
        CanFillComboObjects = False
        CanFillComboMethods = False
    End Sub

    Private Sub cboMethods_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboMethods.SelectedIndexChanged
        Dim aObject As String = Me.cboObjects.Text.Replace("->", "")
        Dim aMethod As String = Me.cboMethods.Text.Replace("->", "")
        CreateMethod(aObject, aMethod)
    End Sub

    Public Sub CreateMethod(ByVal aObject As String, ByVal aMethod As String)
        Dim FunctionCode As String = ""
        FunctionCode &= "  protected function " & aMethod & "()" & vbCrLf
        FunctionCode &= "  {" & vbCrLf
        FunctionCode &= "     //add code here" & vbCrLf
        FunctionCode &= "  }" & vbCrLf & vbCrLf
        If Not Me.Node.ContentCode Like "*protected*function*" & aMethod & "*" Then
            Me.Node.ContentCode = Object_Expression.ReplaceEndClass(Me.Node.ContentCode, FunctionCode)
            Me.Document.Text = Me.Node.ContentCode
        End If
        Me.GotoLine(1)
        Me.FindNext("protected function " & aMethod, False, False, False)
        Me.FindNext("{", False, False, False)
        Me.FindNext(" ", False, False, False)
    End Sub

    Public Sub New()
        Me.AutoListIcons = Object_Icons.bmpImageList

    End Sub

    Public Function GetBreakPoints() As xdc.XDebug.Breakpoint()
        Dim LineWithBreakPoint() As xdc.XDebug.Breakpoint = Nothing
        Dim iRows As Long = Me.Document.Lines.Length
        For i = 0 To iRows - 1
            Dim Fila As Row = Me.Document(i)
            Dim HasBreakPoint As Boolean = False
            If Fila.Breakpoint Then
                HasBreakPoint = True
                If LineWithBreakPoint Is Nothing Then
                    ReDim LineWithBreakPoint(0)
                Else
                    ReDim Preserve LineWithBreakPoint(LineWithBreakPoint.Length)
                End If
                LineWithBreakPoint(LineWithBreakPoint.Length - 1) = New xdc.XDebug.Breakpoint("", Nothing, 0)
                LineWithBreakPoint(LineWithBreakPoint.Length - 1).LineNumber = i
                'LineWithBreakPoint(LineWithBreakPoint.Length - 1).data = Fila.Text
                LineWithBreakPoint(LineWithBreakPoint.Length - 1).filename = Me.Node.Path '"C:\\BeeWitSoft\\AJAXPHPIDE\\Apache\\htdocs\\demo01\\index.php"
            End If
        Next
        Return LineWithBreakPoint
    End Function

End Class
